package a.f.l.a;

import a.c.d;
import a.c.k;
import a.d.n;
import a.d.v;
import a.d.w;
import a.d.y;
import a.f.r;
import a.f.wc;

class b
  extends r
{
  public static final Object g = "y.layout.router.polyline.SelfCrossingRemovalStage.LAYOUT_DESCRIPTOR_DPKEY";
  private final boolean h;
  
  b(boolean paramBoolean)
  {
    this.h = paramBoolean;
  }
  
  public boolean canLayout(a.f.o paramo)
  {
    if ((sb.e) || (a() != null)) {
      return a().canLayout(paramo);
    }
    return true;
  }
  
  public void doLayout(a.f.o paramo)
  {
    boolean bool = sb.e;
    int i = sb.d;
    if ((bool) || (a() != null)) {
      a().doLayout(paramo);
    }
    a.c.m localm = paramo.w();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      while (b(locald, paramo)) {}
      if (!bool)
      {
        if (this.h) {
          a(locald, paramo);
        }
        localm.f();
      }
    } while (i == 0);
  }
  
  private void a(d paramd, a.f.o paramo)
  {
    boolean bool = sb.e;
    int m = sb.d;
    w[] arrayOfw = paramo.n(paramd).h();
    int i = 0;
    label104:
    do
    {
      if (i > arrayOfw.length - 4) {
        break;
      }
      n localn1 = new n(arrayOfw[i], arrayOfw[(i + 1)]);
      n localn2 = new n(arrayOfw[(i + 2)], arrayOfw[(i + 3)]);
      if (!bool) {
        if (bool) {
          break label104;
        }
      }
      Object localObject1 = localn2.b() ? localn2 : localn1.b() ? localn1 : null;
      if (!bool) {
        if (bool) {
          break label143;
        }
      }
      Object localObject2 = localn2.c() ? localn2 : localn1.c() ? localn1 : null;
      if (!bool)
      {
        if ((localObject1 != null) && ((bool) || (localObject2 != null)))
        {
          double d1 = Math.min(localObject1.d().b, localObject1.e().b);
          double d2 = Math.max(localObject1.d().b, localObject1.e().b);
          double d3 = localObject1.d().a;
          double d4 = Math.min(localObject2.d().a, localObject2.e().a);
          double d5 = Math.max(localObject2.d().a, localObject2.e().a);
          double d6 = localObject2.d().b;
          if ((bool) || ((d1 >= d6) || ((bool) || (d2 <= d6))))
          {
            if (bool) {
              continue;
            }
            if (d4 < d3)
            {
              if (bool) {
                continue;
              }
              if (d5 <= d3) {}
            }
          }
          else
          {
            a.c.z localz = new a.c.z();
            int j = 0;
            do
            {
              while (m == 0)
              {
                if (j > i) {
                  break;
                }
                localz.add(arrayOfw[j]);
                j++;
              }
            } while (bool);
            w localw = new w(d3, d6);
            localz.add(localw);
            int k = i + 3;
            if (k < arrayOfw.length)
            {
              localz.add(arrayOfw[k]);
              k++;
            }
            for (;;)
            {
              if ((bool) || (m == 0))
              {
                if (m == 0) {
                  break;
                }
                if (!bool) {
                  paramo.a(paramd, localz);
                }
              }
            }
            return;
          }
        }
        i++;
      }
    } while (m == 0);
    label143:
  }
  
  private boolean b(d paramd, a.f.o paramo)
  {
    boolean bool = sb.e;
    int m = sb.d;
    y localy = wc.e(paramo, paramd);
    int i = localy.j() - 1;
    if ((bool) || (i < 4)) {
      return false;
    }
    k localk = paramo.c(g);
    if (!bool) {}
    o localo = localk == null ? null : (o)localk.get(paramd);
    a.c.z localz = new a.c.z();
    int j = 1;
    Object localObject1 = localy.l();
    Object localObject3;
    Object localObject4;
    label234:
    do
    {
      if (!((v)localObject1).e()) {
        break;
      }
      localObject2 = ((v)localObject1).a();
      if (!bool)
      {
        if ((j == 1) && ((bool) || (localo != null)))
        {
          if (bool) {
            break label234;
          }
          if (localo.a() > 0.0D)
          {
            if (bool) {
              continue;
            }
            if (localo.a() >= ((n)localObject2).h()) {
              break label385;
            }
            localObject3 = ((n)localObject2).i();
            ((a.d.z)localObject3).c();
            ((a.d.z)localObject3).b(localo.a());
            localObject4 = a.d.z.a(((n)localObject2).d(), (a.d.z)localObject3);
            localz.add(new d_((w)localObject4, ((n)localObject2).e(), j, null));
            if (bool) {
              continue;
            }
            if (m == 0) {
              break label385;
            }
          }
        }
        if (bool) {}
      }
      else if (j == i)
      {
        if ((bool) || (localo != null))
        {
          if (bool) {
            break label384;
          }
          if (localo.b() > 0.0D)
          {
            if (bool) {
              continue;
            }
            if (localo.b() >= ((n)localObject2).h()) {
              break label385;
            }
            localObject3 = new a.d.z(((n)localObject2).d(), ((n)localObject2).e());
            ((a.d.z)localObject3).c();
            ((a.d.z)localObject3).b(localo.b());
            localObject4 = a.d.z.a(((n)localObject2).e(), (a.d.z)localObject3);
            localz.add(new d_(((n)localObject2).d(), (w)localObject4, j, null));
            if (bool) {
              continue;
            }
            if (m == 0) {
              break label385;
            }
          }
        }
      }
      localz.add(new d_((n)localObject2, j, null));
      j++;
      ((v)localObject1).f();
    } while (m == 0);
    label384:
    label385:
    localObject1 = new c_(null);
    a.d.m.a(localz, (m.g_)localObject1);
    Object localObject2 = ((c_)localObject1).a;
    if (localObject2 != null)
    {
      localObject3 = localy.h();
      localObject4 = new a.c.z();
      int k = 0;
      do
      {
        do
        {
          if (k >= ((b_)localObject2).a()) {
            break;
          }
          ((a.c.z)localObject4).add(localObject3[k]);
          k++;
          if (bool) {
            break label507;
          }
          if (m != 0) {
            break label502;
          }
        } while (m == 0);
      } while (bool);
      ((a.c.z)localObject4).add(((b_)localObject2).e);
      label502:
      label507:
      k = ((b_)localObject2).c();
      if (k < localObject3.length)
      {
        ((a.c.z)localObject4).add(localObject3[k]);
        k++;
      }
      for (;;)
      {
        if (!bool) {
          if (m == 0)
          {
            if (m == 0) {
              break;
            }
            if (bool) {
              continue;
            }
            paramo.a(paramd, (a.c.z)localObject4);
          }
        }
      }
    }
    return ((c_)localObject1).b;
  }
  
  private static class b_
  {
    final b.d_ a;
    final b.d_ c;
    final w e;
    final int f;
    
    private b_(b.d_ paramd_1, b.d_ paramd_2, w paramw, int paramInt)
    {
      this.a = paramd_1;
      this.c = paramd_2;
      this.e = paramw;
      this.f = paramInt;
    }
    
    public int a()
    {
      return Math.min(this.a.k, this.c.k);
    }
    
    public int c()
    {
      return Math.max(this.a.k, this.c.k);
    }
    
    b_(b.d_ paramd_1, b.d_ paramd_2, w paramw, int paramInt, b.0 param0)
    {
      this(paramd_1, paramd_2, paramw, paramInt);
    }
  }
  
  private static class d_
    extends n
  {
    final int k;
    
    private d_(n paramn, int paramInt)
    {
      this(paramn.d(), paramn.e(), paramInt);
    }
    
    private d_(w paramw1, w paramw2, int paramInt)
    {
      super(paramw2);
      this.k = paramInt;
    }
    
    d_(w paramw1, w paramw2, int paramInt, b.0 param0)
    {
      this(paramw1, paramw2, paramInt);
    }
    
    d_(n paramn, int paramInt, b.0 param0)
    {
      this(paramn, paramInt);
    }
  }
  
  private static class c_
    implements m.g_
  {
    private b.b_ a = null;
    private boolean b = false;
    
    private c_() {}
    
    public void a(Object paramObject1, Object paramObject2)
    {
      boolean bool = sb.e;
      b.d_ locald_1 = (b.d_)paramObject1;
      b.d_ locald_2 = (b.d_)paramObject2;
      w localw = n.a(locald_1, locald_2);
      if (localw != null)
      {
        int i = Math.abs(locald_2.k - locald_1.k);
        if (!bool)
        {
          if (this.a != null) {
            this.b = true;
          }
          if (bool) {}
        }
        else if (this.a != null)
        {
          if (i <= this.a.f) {
            return;
          }
        }
        this.a = new b.b_(locald_1, locald_2, localw, i, null);
      }
    }
    
    c_(b.0 param0)
    {
      this();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.l.a.b

 * JD-Core Version:    0.7.0.1

 */